package com.wxb.shmily.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.wxb.shmily.TestService;
import com.wxb.shmily.bean.user.User;
import com.wxb.shmily.enums.StateEnum;
import com.wxb.shmily.response.Response;
import com.wxb.shmily.response.ResponseUtil;
import com.wxb.shmily.user.api.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shmily on 2018/6/7.
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Reference
    UserService userService;

    @Reference
    TestService testService;

    @RequestMapping("/login")
    public Response login(@RequestParam("nickName") String nickName,@RequestParam("password") String password){
        Response response = null;
        User user = userService.login(nickName,password);
        response = ResponseUtil.success(StateEnum.LOGIN_SUCCESS, user);
        return response;
    }

    @RequestMapping("/test")
    public String test(){
        return testService.get("I'm 格瑞特");
    }
}
